package com.erp.order.supply.dao.impl;

import com.erp.hr.base.dao.impl.BaseDaoImpl;
import com.erp.order.supply.dao.SupplyMaterialDetailDao;
import com.erp.order.supply.model.SupplyMaterialDetail;
import com.erp.order.supply.model.SupplyMaterialR;
import org.redragon.framework.hibernate.DaoSupport;
import org.redragon.framework.hibernate.model.Pages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Repository
public class SupplyMaterialDetailDaoImpl extends BaseDaoImpl<SupplyMaterialDetail> implements SupplyMaterialDetailDao {
    /**
     * dao支持
     */
    @Autowired
    private DaoSupport daoSupport;

    @Override
    public SupplyMaterialDetail getDataObject(String s) {
        return null;
    }

    @Override
    public List<SupplyMaterialDetail> getDataObjects(SupplyMaterialDetail supplyMaterialDetail) {

        return null;
    }

    @Override
    public List<SupplyMaterialDetail> getDataObjectsForDataAuth(String s, Pages pages, SupplyMaterialDetail supplyMaterialDetail) {
        return null;
    }

    @Override
    public SupplyMaterialDetail addCompleteData(SupplyMaterialDetail supplyMaterialDetail) {
        this.daoSupport.insertDataTransaction(supplyMaterialDetail);
        return supplyMaterialDetail;
    }

    @Override
    public List<SupplyMaterialDetail> getDatasByRid(String value) {
        String sql =
                "SELECT " +
                        "smd.* " +
                        "FROM " +
                        "supply_material_detail smd " +
                        "WHERE " +
                        "smd.supply_material_rid = :rid ";
        Map<String, Object> args = new HashMap<>();
        args.put("rid",value);
        Map<String, Class<?>> entity = new HashMap<>();
        entity.put("smd", SupplyMaterialDetail.class);
        List<SupplyMaterialDetail> result = daoSupport.selectDataSql(sql, entity, args);
        return result;
    }
}
